package com.baijiaoxi.common.model.query;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("排序字段")
public class OrderColumn {
    @ApiModelProperty("字段名")
    protected String name;
    @ApiModelProperty(value = "排序类型" , allowableValues = "asc,desc" , notes = "asc:顺序；desc:倒序")
    protected String orderType = "asc";

    public static OrderColumn buildAsc(String name) {
        OrderColumn orderColumn = new OrderColumn();
        orderColumn.setName(name);
        return orderColumn;
    }

    public static OrderColumn buildDesc(String name) {
        OrderColumn orderColumn = new OrderColumn();
        orderColumn.setName(name);
        orderColumn.setOrderType("desc");
        return orderColumn;
    }

    @Override
    public String toString() {
        return "{\"name\"=\""+name+"\",\"orderType\"=\""+orderType+"\"}";
    }
}
